package com.nielsenedu.GameAccount;

import java.util.ArrayList;

public class GamePlatform {

    /** An ArrayList of all player accounts */
    public ArrayList<GameAccount> allPlayers;
    
    /**
     * Returns the average age of players in allPlayers whose age
     * is between 13 and 19, inclusive.
     * Preconditions: allPlayers contains at least one player
     *                whose age is between 13 and 19.
     *                allPlayers is not null and contains no null
     *                elements.
     * Postcondition: allPlayers is unchanged.
     */
    public double avgTeenAccounts() {
        // *** WRITE THE CODE FOR THIS METHOD ***
	return 0.0;
    }
    
    public GamePlatform() {
    	allPlayers = new ArrayList<>();
    }
    
    public boolean addAccount(GameAccount g) {
    	return allPlayers.add(g);
    }
    
    public String toString() {
    	String s = "";
    	for(GameAccount g : allPlayers) {
    		s+= "  " + g.toString() + "\n";
    	}
    	return s;
    }

    public static void main(String[] args) {
		GamePlatform gp = new GamePlatform();
		gp.addAccount(new GameAccount("star_guy",  23));
		gp.addAccount(new GameAccount("a_knight",  14));
		gp.addAccount(new GameAccount("dino_dan",  12));
		gp.addAccount(new GameAccount("cool_cat",  15));
		gp.addAccount(new GameAccount("happy_hero",13));
		gp.addAccount(new GameAccount("fox_sox",   19));
		System.out.print("allPlayers:\n" + gp);
		System.out.println("Average age of teens: " +
                           gp.avgTeenAccounts());
	}

}
